<?php
include("utils.php");

 if($_SESSION['siteuserId']=="")
{
	header("location:index.php");
}


main_content("main();");
function main()
{
	 if($_SESSION['languageId']!="")
{
	$languageId=$_SESSION['languageId'];
}
else
{
	$languageId='1';
}

	$siteUserId=$_SESSION['siteuserId'];

	$selSiteurl=mysql_query("select * from adsite_master where siteuserId='".$siteUserId."'");
	
	if(isset($_POST['next']))
	{
	/*---------allow net starts------*/
		if($_POST['allow_network']=='Y')
		{
			$netVal='Y';
		}
		else
		{
			$netVal='N';
		}
	/*---------allow net ends------*/

	/*---------thumb handle starts------*/
		if($_POST['thumbCompHandle']=='Y')
		{
			$thumHamdleVal='Y';
		}
		else
		{
			$thumHamdleVal='N';
		}
	/*---------thumb handle  ends------*/
	/*---------thumbCompAge starts------*/
		if($_POST['thumbCompAge']=='Y')
		{
			$thumbCompAge='Y';
		}
		else
		{
			$thumbCompAge='N';
		}
	/*---------thumbCompAge ends------*/
	/*---------thumbComplOCATION starts------*/

		if($_POST['thumbComplOCATION']=='Y')
		{
			$thumbComplOCATIONVal='Y';
		}
		else
		{
			$thumbComplOCATIONVal='N';
		}
	/*---------thumbComplOCATION ends------*/
	/*---------thumbCompHeadline starts------*/
		if($_POST['thumbCompHeadline']=='Y')
		{
			$thumbCompHeadlineVal='Y';
		}
		else
		{
			$thumbCompHeadlineVal='N';
		}
	/*---------thumbCompHeadline ends------*/
	/*---------thumbCompImage starts------*/
	if($_POST['thumbCompImage']=='Y')
		{
			$thumbCompImageVal='Y';
		}
		else
		{
			$thumbCompImageVal='N';
		}
	/*---------thumbCompImage ends------*/
	/*---------thumbCustomSize starts------*/
	if($_POST['thumbCustomSize']=='Y')
		{
			$thumbCustomSizeVal='Y';
		}
		else
		{
			$thumbCustomSizeVal='N';
		}
	/*---------thumbCustomSize ends------*/
	/*---------thumbCustomSize starts------*/
	if($_POST['thumbCustomSize']=='Y')
		{
			$thumbCustomSizeVal='Y';
		}
		else
		{
			$thumbCustomSizeVal='N';
		}
	/*---------thumbCustomSize ends------*/

	
		$adSiteId         = $_POST['site_id'];
		$adspaceType      = $_POST['adspace_type'];
		$thumbSize        = $_POST['thumbSize'];
		$thumbView        = $_POST['thumbCount'];
		$thumbCustomWidth = $_POST['width'];
		$thumbCustomHeight= $_POST['height'];
		$thumbOrientation = $_POST['alignment'];
		$thumbbgcolor     = $_POST['background_color'];

		$thumbBodyFontSize        = $_POST['description_font_size'];
		$thumbBodyFontType        = $_POST['description_font_type'];
		$thumbBodyFontColor       = $_POST['description_font_color'];
		$thumbBodyAlign           = $_POST['description_align'];
		$thumbBodyAttriItalic     = $_POST['description_italic'];
		$thumbBodyAttriBold       = $_POST['description_bold'];
		$thumbBodyAttriUnderline  = $_POST['description_underline'];
		
		$thHeaderFontSize       = $_POST['title_font_size'];
		$thHeaderFontType       = $_POST['title_font_type'];
		$thHeaderFontColor      = $_POST['title_font_color'];
		$thHeaderAlign          = $_POST['title_align'];
		$thHeaderAttriItalic    = $_POST['title_italic'];
		$thHeaderAttriBold      = $_POST['title_bold'];
		$thHeaderAttriUnderline = $_POST['title_underline'];


	$selpresentVal=mysql_fetch_array(mysql_query("select * from adspace_master where UserId='".$siteUserId."'"));

	//if($selpresentVal['adspaceId']=='')
	//{
	$insertAdMaster="insert into adspace_master set adsiteId='".$_POST['site_id']."', UserId='".$siteUserId."', langId='".$languageId."'";
	//echo $insertAdMaster;
	$exeAdmaster = mysql_query($insertAdMaster);
	$adspaceId = mysql_insert_id();

	$insertThumbDta= "insert into adspace_details set adspaceId='".$adspaceId."', adspaceType='".$adspaceType."', thumbSize='".$thumbSize."', thumbView='".$thumbView."', thumbCustomSize='".$thumbCustomSizeVal."', thumbCustomWidth='".$thumbCustomWidth."', thumbCustomHeight='".$thumbCustomHeight."', thumbOrientation='".$thumbOrientation."', backgroundColor='".$thumbbgcolor."',allowNetwork='".$netVal."'";
	//echo $insertThumbDta.'<br />';

	$exeinsertAd = mysql_query($insertThumbDta);

	if($_REQUEST['insertmode']=='insertheader')
	{
		$insertThumbheader="insert into thumb_header set adspaceId='".$adspaceId."', thHeaderFontSize='".$thHeaderFontSize."', thHeaderFontType='".$thHeaderFontType."', thHeaderFontColor='".$thHeaderFontColor."', thHeaderAlign='".$thHeaderAlign."', thHeaderAttriItalic='".$thHeaderAttriItalic."', thHeaderAttriBold='".$thHeaderAttriBold."', thHeaderAttriUnderline ='".$thHeaderAttriUnderline."'";
		//echo $insertThumbheader;

		$exeThumbheader=mysql_query($insertThumbheader);
	}
	if($_REQUEST['insertmode']=='insertbody')
	{
		
		$insertThumbBody="insert into thumb_body set adspaceId='".$adspaceId."', thumbBodyFontSize='".$thumbBodyFontSize."', thumbBodyFontType='".$thumbBodyFontType."', thumbBodyFontColor='".$thumbBodyFontColor."', thumbBodyAlign='".$thumbBodyAlign."', thumbBodyAttriItalic='".$thumbBodyAttriItalic."', thumbBodyAttriBold='".$thumbBodyAttriBold."', thumbBodyAttriUnderline ='".$thumbBodyAttriUnderline."'";
		//echo $insertThumbBody;

		$exeThumbBody=mysql_query($insertThumbBody);
	}

	$_SESSION['adspaceId']=$adspaceId;

	//}
	//else
	//{

	//$upDateThumbData = "update adspace_details set adspaceType='".$_POST['adspace_type']."',adSize='".$_POST['size']."',fontType='".$_POST['font_type']."',backgroundColor='".$_POST['background_color']."',noOfTextAd='".$_POST['cell_count']."',headerColor='".$_POST['title_color']."',thumbOrientation='".$_POST['alignment']."',bodyColor='".$_POST['description_color']."' where UserId='".$siteUserId."' and adspaceId='".$adspaceId."'";
	//echo $upDateAd;
	//$exeThumbData = mysql_query($upDateThumbData);
	//echo '<script>window.location="customize_ad.php?sid='.$siteUserId.'"</script>';
	//}
//header("location:sell_space_add_details.php");
	
	}

?>

<link rel="stylesheet" href="css/style.css" type="text/css">
  
  <script type="text/javascript" language="javascript" src="JavaScripts/common.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/popup-layer.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/category-list.js"></script>
  <script type="text/javascript" language="javascript" src="JavaScripts/cover.js"></script>
<div id="colorlayer" onMouseOver="javascript:enterColorPalette()" onMouseOut="javascript:leaveColorPalette()" class="drag" style="visibility: hidden; width: 204px; height: 142px; position: absolute; z-index: 1;">
  <table bgcolor="#ffffff" border="0" cellpadding="1" cellspacing="2" width="100%">
    <tbody>
    <tr>
        <td id="selectedcolor" width="12%"></td>
        <td id="colorcode" align="center" width="75%"></td>
        <td width="12%">
          <div id="transparent" style="cursor: pointer; visibility: inherit;">
            <img src="images/transparent.gif" onMouseOver="javascript:onTransparent();" onClick="javascript:onClickTransparent();preview();">
          </div>
        </td>
    </tr>
    </tbody>
  </table>
  <table id="colortable" style="border: 1px solid rgb(127, 157, 185); cursor: pointer; height: 115px;" bgcolor="#ffffff" border="0" cellpadding="1" cellspacing="2" width="100%">
    <tbody></tbody>
  </table>
  <iframe src="blank_004.html" style="position: absolute; visibility: inherit; top: 0px; left: 0px; width: 204px; height: 142px; z-index: -1;" frameborder="0">
  </iframe>
</div>


<script language="javascript" type="text/javascript">
<!--
    var transparent = "TRANSPARENT";

    var ns = document.getElementById&&!document.all; //boolean flag for netscape/firefox
    var objId; //object id
    var selected; //selected color
    var onchangeFlag = false;
    init();

    //Initialize the color table.
    function init() {
        var colors = new Array (
            ['#FF8080', '#FFFF80', '#80FF80', '#00FF80', '#80FFFF', '#0080FF', '#FF80C0', '#FF80FF'],
            ['#FF0000', '#FFFF00', '#80FF00', '#00FF40', '#00FFFF', '#0080C0', '#8080C0', '#FF00FF'],
            ['#804040', '#FF8040', '#00FF00', '#008080', '#004080', '#8080FF', '#800040', '#FF0080'],
            ['#800000', '#FF8000', '#008000', '#008040', '#0000FF', '#0000A0', '#800080', '#8000FF'],
            ['#400000', '#804000', '#004000', '#004040', '#000080', '#000040', '#400040', '#400080'],
            ['#000000', '#808000', '#808040', '#808080', '#408080', '#C0C0C0', '#400040', '#FFFFFF']
        );
        var table = document.getElementById("colortable");

        for (itr in colors) {
            var row = table.insertRow(-1);
            for (itd in colors[itr]) {
                var cell = row.insertCell(-1);
                cell.height = 17;
                cell.innerText = "";
                cell.bgColor = colors[itr][itd];

                //when move mouse to a cell, the selected color will changed
                cell.onmouseover = function() {
                    var colorcode = document.getElementById("colorcode");
                    colorcode.innerHTML = "<b>" + this.bgColor.toUpperCase() + "</b>";
                    var selectedcolor = document.getElementById("selectedcolor");
                    selectedcolor.bgColor = this.bgColor;
                    selected = selectedcolor;
                }
                //when mouse click, the selected color will be assigned to obj
                //and color palette will be closed
                cell.onclick  = function(){
                    if (objId != '') {
                        var obj = document.getElementById(objId);
                    }
                    obj.value = selected.bgColor.toUpperCase();
                    if (obj.onchange) {
                        obj.onchange();
                    }                    
                    onClickPalette('', null);
                    preview();
                };
            }
        }
    }


    //It is called when mouse over transparent cell
    function onTransparent() {
        var colorcode = document.getElementById("colorcode");
        colorcode.innerHTML = "<b>" + transparent + "</b>";
        var selectedcolor = document.getElementById("selectedcolor");
        selectedcolor.bgColor = "Transparent";
    }


    //It is called when mouseclick on transparent cell
    function onClickTransparent() {
        if (objId != '') {
            var obj = document.getElementById(objId);
        }
        obj.value = 'TRANSPARENT';
        onClickPalette('', null);
    }

    //show or hide the palette
    //it also inits table data and div position
    function onClickPalette(objid, control, isTran, leftTopDisplay) {
        if (!document.all && onchangeFlag) {
            return;
        }
        var l = 0;
        var t = 0;
        var obj;
        if (objid != '') {
            obj = document.getElementById(objid);
            objId = objid;
        }

        //check that needs the transparent or not
        var transparent = document.getElementById("transparent");
        if (typeof(isTran) != "undefined") {
            transparent.style.visibility = (isTran) ? "inherit" : "hidden";
        }
        else {
            transparent.style.visibility = "hidden";
        }

        //calculate the control position
        if (control != null) {
            controlTop = control.offsetTop;
            controlLeft = control.offsetLeft + 20;
            while(control = control.offsetParent) {
                controlTop += control.offsetTop;
                controlLeft += control.offsetLeft;
            }
        }

        //init div position
        var div = document.getElementById('colorlayer');
        if (leftTopDisplay != null) {
            leftDistance = controlLeft - div.offsetWidth;
            topDistance = controlTop - div.offsetHeight;
            div.style.left = leftDistance + "px";
            div.style.top = topDistance + "px";
        }
        else {
            div.style.left = controlLeft + "px";
            div.style.top = controlTop + "px";
        }

        //init div data
        if (div.style.visibility == 'hidden') {
            var selectedcolor = document.getElementById('selectedcolor');
            selectedcolor.bgColor = obj.value;
            var colorcode = document.getElementById('colorcode');
            colorcode.innerHTML = "<b>" + obj.value.toUpperCase() + "</b>";
        }

        div.style.visibility = (div.style.visibility == 'hidden') ? 'visible' : 'hidden';
    }

    var inColorPalette = false;
    function mousedown() {
        if (!inColorPalette) {
            var div = document.getElementById('colorlayer');
            div.style.visibility = 'hidden';
        }
    }

    function leaveColorPalette() {
        inColorPalette=false;
    }

    function enterColorPalette() {
        inColorPalette=true;
    }

    document.onmousedown = mousedown;

-->
</script><script language="javascript" type="text/javascript">
<!--
    var adspaceOnload = window.onload;
    window.onload = function() {
        if (adspaceOnload) {
            adspaceOnload();
        }
        if (document.getElementById('adspaceType')) {
            document.getElementById("adspaceType").value = 'customize_commBreak.php';
        }
        else {
            addLinksCheckChange(message);
        }
    }
-->
</script>

<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
              <tr>
                <td valign="top" align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>&nbsp;</td>
                    <td valign="top" align="center"><table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderTopLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxTopBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderTopRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr>
                    <td class="PinkTwosideBorder BoxContent" valign="top"><table class="center" cellspacing="0" cellpadding="0" width="100%">
  
  <tr>
    <td align="left" valign="top"><table width="100%" cellspacing="0" cellpadding="0">
  
  <tr>
    <td align="left" valign="top" >

	<form id="cbLayout" name="cb_layout" enctype="multipart/form-data" method="post" action="" class="tight-layout">
<table id="cbAdspaceAdd" style="margin-left: 5px;" class="normal-table" align="center">
  <tbody><tr valign="top">
    <td style="">
    <table style="background-color: rgb(153, 153, 153); width: 100%;" cellpadding="3" cellspacing="1">
  <tbody><tr>
    <td style="text-align: left; color: rgb(255, 255, 255); font-weight: bold;" class="sitename">Ad Space Characteristics</td>
  </tr>
  <tr style="background-color: rgb(251, 251, 251);">
    <td>
      
    <div style="padding: 3px; text-align: left;">
        <table style="text-align: left;" class="normal-table" align="center">
            <tbody>
                <tr>
                    <td colspan="2" class="blackbold" style="text-align: left;">
                        Ad Space Type:
                        <select id="adspaceType" name="adspace_type" class="flat blackbold" onchange="var newValue=this.value;this.selectedIndex=3;window.location.href=newValue;">
                            <option value="text" onclick="window.location='customize_ad.php'">Text</option>
                            <option value="banner" onclick="window.location='customize_banner.php'">Banner</option>
                            <option value="thumbnail" onclick="window.location='customize_thumbnail.php'">Thumbnail</option>
                            <option value="customize_commBreak" selected="selected" onclick="window.location='customize_commBreak.php'">
                                Commercial Break</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <hr border="0" style="border-top: 1px solid rgb(51, 51, 51); width: 325px;">
                    </td>
                </tr>
                <tr>
                    <td>
                        Choose a Web Site:
                    </td>
                    <td>
                        <select id="siteId" name="site_id" class="flat" onchange="javascript:preview();changeRating();">
                            <option label="Please Select" value="0" selected="selected">Please Select</option>
                            <option label="esolzdemos(NSFW)" value="72687">esolzdemos(NSFW)</option>
                            <option label="test(NSFW)" value="72719">test(NSFW)</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        Rating:
                    </td>
                    <td>
                        <span id="websiteRating"></span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table>
                            <tbody>
                                <tr>
                                    <td class="blackbold" colspan="2">
                                        Background:
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        Height:
                                        <select class="flat" id="height" name="height" onchange="javascript:preview()">
                                            <option label="63" value="63" selected="selected">63</option>
                                            <option label="64" value="64">64</option>
                                            <option label="65" value="65">65</option>
                                            <option label="66" value="66">66</option>
                                            <option label="67" value="67">67</option>
                                            <option label="68" value="68">68</option>
                                            <option label="69" value="69">69</option>
                                            <option label="70" value="70">70</option>
                                            <option label="71" value="71">71</option>
                                            <option label="72" value="72">72</option>
                                            <option label="73" value="73">73</option>
                                            <option label="74" value="74">74</option>
                                            <option label="75" value="75">75</option>
                                            <option label="76" value="76">76</option>
                                            <option label="77" value="77">77</option>
                                            <option label="78" value="78">78</option>
                                            <option label="79" value="79">79</option>
                                            <option label="80" value="80">80</option>
                                            <option label="81" value="81">81</option>
                                            <option label="82" value="82">82</option>
                                            <option label="83" value="83">83</option>
                                            <option label="84" value="84">84</option>
                                            <option label="85" value="85">85</option>
                                            <option label="86" value="86">86</option>
                                            <option label="87" value="87">87</option>
                                            <option label="88" value="88">88</option>
                                            <option label="89" value="89">89</option>
                                            <option label="90" value="90">90</option>
                                            <option label="91" value="91">91</option>
                                            <option label="92" value="92">92</option>
                                            <option label="93" value="93">93</option>
                                            <option label="94" value="94">94</option>
                                            <option label="95" value="95">95</option>
                                            <option label="96" value="96">96</option>
                                            <option label="97" value="97">97</option>
                                            <option label="98" value="98">98</option>
                                            <option label="99" value="99">99</option>
                                            <option label="100" value="100">100</option>
                                        </select>
                                        pixels
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        Color:
                                        <input id="backgroundColor" name="background_color" class="flat" size="10" maxlength="11"
                                            value="#6699CC" onchange="javascript:commonPreview(preview);" type="text"><a class="colorformat">Background
                                                Color</a>
                                        <img id="backgroundColorIcon" style="cursor: pointer; padding-left: 3px;" src="images/palette.gif"
                                            alt="Palette" onclick="javascript: onClickPalette('backgroundColor', this, true);">
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <span class="blackbold">Upload Background:</span> (Optional)
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        Background:
                                    </td>
                                    <td>
                                        <span id="upload_bg_node">
                                            <input id="uploadBackground" name="upload_backgound" onchange="javascript:if (prepareForPreview('upload_backgound') != false)preview();"
                                                type="file"></span>
                                        <input value="Clear" class="blank-button-small" onclick="javascript:clearBackground()"
                                            type="button">
                                        <input id="useBackground" name="use_background" value="false" type="hidden">
                                        <input id="uploadNewBackground" name="upload_new_background" value="false" type="hidden">
                                        <input id="uploadedBackgroundFileName" name="uploaded_background_file_name" value=""
                                            type="hidden">
                                        <input id="uploadAction" name="upload_action" value="" type="hidden">
                                        <div>
                                            (Max. 90 KB.Accepted formats: jpeg, gif, png.)</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <hr border="0" style="border-top: 1px solid rgb(51, 51, 51); width: 325px;">
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table style="width: 330px;">
                            <tbody>
                                <tr>
                                    <td colspan="2" class="blackbold">
                                        Publisher:
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Font Size:
                                    </td>
                                    <td>
                                        <select id="fontSize" name="font_size" class="flat" onchange="javascript:preview()">
                                            <option label="1" value="8">1</option>
                                            <option label="2" value="9">2</option>
                                            <option label="3" value="10">3</option>
                                            <option label="4" value="11">4</option>
                                            <option label="5" value="12">5</option>
                                            <option label="6" value="13">6</option>
                                            <option label="7" value="14">7</option>
                                            <option label="8" value="15">8</option>
                                            <option label="9" value="16">9</option>
                                            <option label="10" value="17">10</option>
                                            <option label="11" value="18">11</option>
                                            <option label="12" value="19" selected="selected">12</option>
                                        </select>
                                        points
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Font Type:
                                    </td>
                                    <td>
                                        <select id="fontType" name="font_type" class="flat" onchange="javascript:preview()">
                                            <option label="Arial" value="Arial" selected="selected">Arial</option>
                                            <option label="Georgia" value="Georgia">Georgia</option>
                                            <option label="Sans-serif" value="MS Sans Serif">Sans-serif</option>
                                            <option label="Times" value="Times">Times</option>
                                            <option label="Verdana" value="Verdana">Verdana</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Color:
                                    </td>
                                    <td>
                                        <input id="fontColor" name="font_color" class="flat" size="10" maxlength="11" value="#FFFFFF"
                                            onchange="javascript:commonPreview(preview);" type="text"><a class="colorformat">Font
                                                Color</a>
                                        <img id="fontColorIcon" style="cursor: pointer; padding-left: 3px;" src="images/palette.gif"
                                            alt="Palette" onclick="javascript: onClickPalette('fontColor', this, false);">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Attributes:
                                    </td>
                                    <td>
                                        <span style="padding-right: 5px;">
                                            <input id="fontBold" name="font_bold" onclick="javascript: preview();" type="checkbox"><label
                                                for="fontBold">Bold</label></span> <span style="padding-right: 5px;">
                                                    <input id="fontUnderline" name="font_underline" onclick="javascript: preview();"
                                                        type="checkbox"><label for="fontUnderline">Underline</label></span>
                                        <span>
                                            <input id="fontItalic" name="font_italic" onclick="javascript: preview();" type="checkbox"><label
                                                for="fontItalic">Italic</label></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <span class="blackbold">Upload Logo:</span> (Optional)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Logo:
                                    </td>
                                    <td>
                                        <span id="upload_logo_node">
                                            <input id="uploadLogo" name="upload_logo" onchange="javascript:if (prepareForPreview('upload_logo') != false) preview();"
                                                type="file"></span>
                                        <input value="Clear" class="blank-button-small" onclick="javascript:clearLogo()"
                                            type="button">
                                        <input id="useLogo" name="use_logo" value="false" type="hidden">
                                        <input id="uploadNewLogo" name="upload_new_logo" value="false" type="hidden">
                                        <input id="uploadedLogoFileName" name="uploaded_logo_file_name" value="" type="hidden">
                                        <div>
                                            (Max. 90 KB.Accepted formats: jpeg, gif, png.)</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <hr border="0" style="border-top: 1px solid rgb(51, 51, 51); width: 325px;">
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <div style="display: none;">
                            <input id="showSkip" name="show_skip" onclick="javascript: preview();" checked="checked"
                                type="checkbox">
                            <label for="showSkip">
                                <span class="blackbold">Show Skip Ad Button</span></label>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    </td>
  </tr>
</tbody></table>
    <div style="text-align: right; padding-top: 10px;">
      <input name="back" value="&lt; Back" class="blank-button-small" onClick="javascript: goBack()" type="button">
            <input name="next" value="Next &gt;" class="yellow-button-small" onClick="javascript: return validateSite();" type="submit">
          </div>
    </td>
    <td style="width: 50%;">
    <table style="background-color: rgb(153, 153, 153); width: 100%;" cellpadding="3" cellspacing="1">
  <tbody><tr>
    <td style="text-align: left; color: rgb(255, 255, 255); font-weight: bold;" class="sitename">Preview</td>
  </tr>
  <tr style="background-color: rgb(251, 251, 251);">
    <td>
      
        <div style="padding: 3px; text-align: left;">
            <div id="previewAreaHolder" style="width: 485px;">

                <script type="text/javascript" language="javascript" src="selling-cb-adspace-add_files/common.js"></script>

                <div id="cb_ad_preview">
                    <div id="adHeader" style="border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 0px;
                        width: 100%; height: 63px; background-color: rgb(102, 153, 204); background-image: url();">
                        <table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr id="headerBody" style="margin: 0px; padding: 0px; vertical-align: middle; height: 41px;">
                                    <td style="text-align: left; padding-left: 20px;">
                                        <div id="publisherLogo" style="font-size: 19px; font-family: Arial; color: rgb(255, 255, 255);
                                            font-weight: normal; text-decoration: none; font-style: normal;">
                                            Publisher Site Name</div>
                                    </td>
                                    <td style="text-align: right; padding-right: 20px;">
                                        <div style="display: block;" id="skipButton">
                                            <input value="Skip Ad &gt;&gt;" style="border-width: 0px; font-family: verdana; font-size: 12px;
                                                color: rgb(0, 0, 0); font-weight: bold; background-color: transparent; background-image: url(images/cb_skip_ad_button.gif);
                                                width: 100px; height: 22px;" type="button">
                                        </div>
                                    </td>
                                </tr>
                                <tr style="vertical-align: middle; text-align: left;">
                                    <td colspan="2" style="margin: 0px; padding: 0px;">
                                        <div style="background-image: url(images/cb_advertiser_bg.gif); height: 22px; padding-left: 20px;">
                                            <span style="font-family: verdana; font-size: 11px; color: rgb(0, 0, 0);">An Advertisement
                                                By <span id="advertiserName" style="font-weight: bold;">Advertiser Name</span>
                                                <img src="images/arrow_down.png" style="padding-top: 7px;">
                                            </span>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

                <script language="javascript" type="text/javascript">
<!--
var uploadFinish = false;
var ad_style = {
    'bg_height' : '63',
    'bg_color' : '#6699CC',
    'use_bg_img' : false,
    'bg_img_src' : '',
    'font_size' : '19',
    'font_type' : 'Arial',
    'font_color' : '#FFFFFF',
    'font_bold' : 'normal',
    'font_underline' : 'none',
    'font_italic' : 'normal',
    'use_logo' : false,
    'logo_src' : '',
    'show_skip' : true,
    'site_name' : 'Publisher Site Name',
    'advertiser_name' : 'Advertiser Name',
    'body_src' : ''
};

var oldOnload = window.onload;
window.onload = function () {
    if (oldOnload) {
        oldOnload();
    }
    refreshAd();
        if ('' != ad_style.body_src) {
        if (document.getElementById('adBody')) {
            window.frames['ad_body'].location.replace(ad_style.body_src);
        }
    }
};

var refreshAd = function() {
    var ad_header = document.getElementById('adHeader');
    ad_header.style.height = ad_style.bg_height + 'px';
    ad_header.style.backgroundColor = ad_style.bg_color;
    ad_header.style.backgroundImage = 'url("'+ad_style.bg_img_src+'")';
    var headerBody = document.getElementById('headerBody');
    headerBody.style.height = ad_style.bg_height - 22 + 'px';
    var publisher_logo = document.getElementById('publisherLogo');
    var previewAreaHolder = document.getElementById('previewAreaHolder');
    if (ad_style.use_logo) {
        if (document.getElementById("previewAreaHolder") != null && !(navigator.userAgent.indexOf("MSIE 6.0") > 0)) { //fix browser compatibility when preview publisher logo
            if (!uploadFinish) {
                setTimeout(refreshAd, 1000);
                return;
            }
        }
        publisher_logo.innerHTML = '<img src="'+ad_style.logo_src+'" onload="if(\'function\' == typeof(resizeAdHeader)){resizeAdHeader(this);}" />';
    }
    else {
        publisher_logo.style.fontSize = ad_style.font_size + 'px';
        publisher_logo.style.fontFamily = ad_style.font_type;
        publisher_logo.style.color = ad_style.font_color;
        publisher_logo.style.fontWeight = ad_style.font_bold;
        publisher_logo.style.textDecoration = ad_style.font_underline;
        publisher_logo.style.fontStyle = ad_style.font_italic;
        publisher_logo.innerHTML = ad_style.site_name;
        if (publisher_logo.scrollHeight > parseInt(headerBody.style.height)) {
            ad_header.style.height = publisher_logo.scrollHeight + 22 + 'px';
            ad_header.style.height = publisher_logo.scrollHeight + 22 + 'px'; //this statement is not duplicated but necessary
        }
    }

    document.getElementById('skipButton').style.display = ad_style.show_skip ? 'block' : 'none';
    if ('' == document.getElementById('advertiserName').innerHTML) {
        document.getElementById('advertiserName').innerHTML = htmlSpecialChars(ad_style.advertiser_name);
    }
};

var resizeAdHeader = function(obj) {
    if ((navigator.userAgent.indexOf("MSIE 6.0") > 0))  return;
    if (true == ad_style.use_logo) {
        var win_height = document.getElementById('adHeader').clientHeight;
        var total_height = obj.height + 22;
        document.getElementById('adHeader').style.height = win_height  + 'px';
        if (total_height > win_height) {
            document.getElementById('adHeader').style.height = total_height + 'px';
        }
    }
    if (document.getElementById("previewAreaHolder") != null) {
        resizeAdHeaderWidth();
    }
};

var resizeAdHeaderWidth = function() {
    resetTableStyle();
    var ad_header = document.getElementById('adHeader');
    var publisher_logo = document.getElementById('publisherLogo');
    var previewAreaHolder = document.getElementById('previewAreaHolder');
    if (isIE7()) {
        ad_header.style.width = ad_header.scrollWidth;
    }
    else {
        //resize adHeader div width
        var adHeaderWidth = publisher_logo.clientWidth + document.getElementById('skipButton').clientWidth;
        var adHeaderBorder = parseInt(ad_header.style.border) * 2;
        previewAreaHolder.style.width = ((adHeaderWidth + adHeaderBorder + 20) > 370) ? "100%" : "370px";
    }
    centerTablePosition();
};

var centerTablePosition = function() {
    var controlLayer = document.getElementById('control');
    var tableWidth = document.getElementById("cbAdspaceAdd").clientWidth;
    var defaultTableWidth = (isIE7()) ? 746 : 744;
    if (controlLayer && tableWidth > defaultTableWidth) {
        controlLayer.style.width = tableWidth + 'px';
    }
};

var changeName = function(name) {
    document.getElementById('advertiserName').innerHTML = htmlSpecialChars(name);
};

var changeUrl = function(src) {
    if (document.getElementById('adBody')) {
        if (isUrl(src)) {
            window.frames['ad_body'].location.replace(src);
        }
    }
};

-->
</script>

                <div id="notice" style="color: red; display: none;">
                    Notice: Preview may not display correctly due to security settings in your browser.</div>
            </div>
        </div>
    </td>
  </tr>
</tbody></table>
    <div style="text-align: right; padding-top: 5px;">
      <input value="Preview Full Size" class="blank-button-big" onClick="javascript:showFullSize()" type="button">
    </div>
    </td>
  </tr>
</tbody></table>
<iframe name="hidden_frame" id="hidden_frame" style="display: none;" src="selling-cb-adspace-add_files/blank_004.html" frameborder="0"></iframe>
</form>		
	
<script language="javascrip" type="text/javascript">
<!--

var changed = false;
var bgColorIconOnclick = document.getElementById("backgroundColorIcon").onclick;
var fontColorIconOnclick = document.getElementById("fontColorIcon").onclick;

var prepareForPreview = function(uploadAction) {
    uploadFinish = false;
    var path = null;
    if (uploadAction == 'upload_backgound') {
        path = document.getElementById("uploadBackground").value;
    }
    else if (uploadAction == 'upload_logo') {
        path = document.getElementById("uploadLogo").value;
    }
    if (path != "") {
        path = "file://" + path;
        path = path.replace('\\', '/');
        arrList = path.split(".");
        fileType = arrList[arrList.length-1].toLowerCase();
        if (uploadAction == 'upload_backgound') {
            document.getElementById('useBackground').value = 'true';
        }
        else if (uploadAction == 'upload_logo') {
            document.getElementById('useLogo').value = 'true';
        }
        if (!isAllowedUploadFileType(fileType)) {
            uploadFinish = true;
            return false;
        }
    }
    document.getElementById("cbLayout").target = "hidden_frame";
    document.getElementById("uploadAction").value = uploadAction;
    document.getElementById("cbLayout").action = "selling-cb-adspace-upload-image.php";   
    document.getElementById("cbLayout").submit();
}

var isAllowedUploadFileType = function(fileType) {
    return (fileType == 'gif') || (fileType == 'jpg') || (fileType == 'jpeg') || (fileType == 'png');
}

var preview = function() {
    backgroundColor = document.getElementById('backgroundColor');
    fontColor = document.getElementById("fontColor");
    var reg = /^#[0-9a-fA-F]{6}$/;
    if ('TRANSPARENT' != backgroundColor.value && ! reg.test(backgroundColor.value)) {
        alert(alert_color_incorrect.replace('<field name>', backgroundColor.nextSibling.firstChild.nodeValue));
        focusElement(backgroundColor);
        return;
    }
    if (!reg.test(fontColor.value)) {
        alert(alert_color_incorrect.replace('<field name>', fontColor.nextSibling.firstChild.nodeValue));
        focusElement(fontColor);
        return;
    }
    if (siteId = document.getElementById('siteId')) {
        if (siteId.selectedIndex > 0) {
            siteName = website_name[siteId.options[siteId.selectedIndex].value];
            ad_style.site_name = htmlSpecialChars(siteName);
        }
        else {
            ad_style.site_name = publisher_site_name;
        }
    }
    ad_style.bg_height = document.getElementById('height').value;
    ad_style.bg_color = document.getElementById('backgroundColor').value;
    var background_path = document.getElementById("uploadBackground").value;
    if (background_path != '') {
        var reg = /^#[0-9a-fA-F]{6}$/;
        if (!reg.test(ad_style.bg_color) && ("TRANSPARENT" != ad_style.bg_color.toUpperCase())) {
            document.getElementById('backgroundColor').value = document.getElementById('backgroundColor').defaultValue;
        }
        document.getElementById('useBackground').value='true';
        document.getElementById('uploadNewBackground').value='true';
        ad_style.use_bg_img = true;
        document.getElementById('backgroundColor').disabled = true;
        document.getElementById('backgroundColorIcon').onclick = null;
    }

    ad_style.font_size = document.getElementById("fontSize").value;
    ad_style.font_color = document.getElementById("fontColor").value;
    ad_style.font_type = document.getElementById("fontType").value;
    ad_style.font_bold = document.getElementById("fontBold").checked ? "bold" : "normal";
    ad_style.font_underline = document.getElementById("fontUnderline").checked ? "underline" : "none";
    ad_style.font_italic = document.getElementById("fontItalic").checked ? "italic" : "normal";
    ad_style.show_skip = document.getElementById("showSkip").checked ? true : false;

    var logo_path = document.getElementById("uploadLogo").value;
    if (logo_path != "") {
        var reg = /^#[0-9a-fA-F]{6}$/;
        if (!reg.test(ad_style.font_color) && ("TRANSPARENT" != ad_style.font_color.toUpperCase())) {
            document.getElementById('fontColor').value = document.getElementById('fontColor').defaultValue;
        }
        document.getElementById('useLogo').value='true';
        document.getElementById('uploadNewLogo').value='true';
        ad_style.use_logo = true;
        document.getElementById('fontSize').disabled = true;
        document.getElementById('fontType').disabled = true;
        document.getElementById('fontColor').disabled = true;
        document.getElementById('fontBold').disabled = true;
        document.getElementById('fontUnderline').disabled = true;
        document.getElementById('fontItalic').disabled = true;
        document.getElementById('fontColorIcon').onclick = null;
    }
    refreshAd();
    changed=true;
};

var clearBackground = function() {
    document.getElementById('useBackground').value = 'false';
    document.getElementById("upload_bg_node").innerHTML = '<input id="uploadBackground" name="upload_backgound" type="file" onchange="javascript:if (prepareForPreview(\'upload_backgound\') != false)preview();"/>';
    ad_style.use_bg_img = false;
    ad_style.bg_img_src = '';
    document.getElementById('backgroundColor').disabled = false;
    document.getElementById('backgroundColorIcon').onclick = bgColorIconOnclick;
    refreshAd();
    changed=true;
};

var clearLogo = function() {
    document.getElementById('useLogo').value = 'false';
    document.getElementById("upload_logo_node").innerHTML = '<input id="uploadLogo" name="upload_logo" type="file" onchange="javascript: if (prepareForPreview(\'upload_logo\') != false) preview();" />';
    ad_style.use_logo = false;
    ad_style.logo_src = '';
    document.getElementById('fontSize').disabled = false;
    document.getElementById('fontType').disabled = false;
    document.getElementById('fontColor').disabled = false;
    document.getElementById('fontBold').disabled = false;
    document.getElementById('fontUnderline').disabled = false;
    document.getElementById('fontItalic').disabled = false;
    document.getElementById('fontColorIcon').onclick = fontColorIconOnclick;
    refreshAd();
    resetTableStyle();
    changed=true;
};

var resetTableStyle = function() {
    if (document.getElementById('control') != null) {
        document.getElementById('control').style.width = "700px";
    }
    if (!document.all) {
        document.getElementById("previewAreaHolder").style.width = "370px";   
    }
    else if (isIE7()) {
        document.getElementById("adHeader").style.width = "370px";
    }
};

var pageOnload = window.onload;
window.onload = function() {
    if (pageOnload) {
        pageOnload();
    }
    if (document.getElementById('useBackground').value == 'true') {
        document.getElementById('backgroundColor').disabled = true;
        document.getElementById('backgroundColorIcon').onclick = null;
    }
    if (document.getElementById('useLogo').value == 'true') {
        document.getElementById('fontSize').disabled = true;
        document.getElementById('fontType').disabled = true;
        document.getElementById('fontColor').disabled = true;
        document.getElementById('fontBold').disabled = true;
        document.getElementById('fontUnderline').disabled = true;
        document.getElementById('fontItalic').disabled = true;
        document.getElementById('fontColorIcon').onclick = null;
    }
    changeRating();
}

function changeRating() {
    var website = document.getElementById('siteId');
    var contentRating = ratings[websites_rating[website.value]];
    document.getElementById('websiteRating').innerHTML = (contentRating) ? contentRating : '';
}

var goBack = function() {
    if (changed) {
        if (confirm(message)) {
            return;
        }
    }
    window.location.href='selling-adspace-list.php' + base_url;
};

var websites_rating = new Array();
    websites_rating['72687'] = 'nsfw';
    websites_rating['72719'] = 'nsfw';
var ratings = {'sfw' : 'Safe For Work', 'nsfw' : 'Not Safe For Work', 'adult' : 'Adult'};
var base_url = '?sid=76f35196c884c2ef8f640a5348795394';
var message = 'Do you want to save your changes?';
var publisher_site_name = 'Publisher Site Name';
var website_name = {
        '0' : 'Please Select',
        '72687' : 'esolzdemos',
        '72719' : 'test',
        '' : ''
};
function validateSite() {
document.getElementById("cbLayout").target = "_parent";
document.getElementById("cbLayout").action = "";
    if ("0" == document.getElementById("siteId").value) {
        alert("Please choose a website from the dropdown list");
        document.getElementById("siteId").focus();
        return false;
    }
    if (!!document.all) {
        var background = document.getElementById("uploadBackground").value;
        var logo = document.getElementById("uploadLogo").value;
        var reg = /^[a-zA-Z]:/;
        if ((background && !reg.test(background)) || (logo && !reg.test(logo))) {
            var error_message = "ERROR:You have uploaded an incorrect file type. Supported image type: JPG, PNG, GIF.";
            if (document.getElementById("pageError"))
                document.getElementById("pageError").innerHTML = error_message;
            else {
                document.getElementById("localPageError").style.display = 'block';
                document.getElementById("localPageError").innerHTML = error_message;
            }
        }
    }
    return validateForm(document.getElementById("cbLayout"));
}
var showFullSize = function() {
    var win_height = document.getElementById('cb_ad_preview').scrollHeight;
    win_height += 25;
    var win_pop = window.open('about:blank', '_blank', 'height='+win_height+',toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no');
    win_pop.document.write('<html><head><title>Ad Space Preview</title>');
    win_pop.document.write('<script type="text/javascript">window.onload=function(){if (document.getElementById("adHeader")) document.getElementById("adHeader").style.width = "100%";}');
    win_pop.document.write('</scrip' + 't>');
    win_pop.document.write('<style>body{margin:0px;background-color:#FFFFFF;color:#5E5E5E;font-size:11px;font-family:Tahoma,Arial,Helvetica,San-serif;}.blackbold{color:#000000;font-weight:bold;}');
    win_pop.document.write('a:link,a:visited{text-decoration:none;color:#5E5E5E;font-size:11px;}a:hover{text-decoration:none;color: #10215A;font-size:11px;}</style>');
    win_pop.document.write('</head><body style="margin:0px"><div id="cb_ad_preview">');
    win_pop.document.write(document.getElementById('cb_ad_preview').innerHTML);
    win_pop.document.write('</div>');
    if ('block' == document.getElementById('notice').style.display) {
        win_pop.document.write('<div style="color:red">'+document.getElementById('notice').innerHTML+'</div>');
    }
    win_pop.document.write('<div style="text-align:center;padding-top:5px"><a id="closeLink" href="#" onclick="window.close()" onmouseover="return true;" class="blackbold" title="Close Window">[CLOSE]</a></div>');
    win_pop.document.write('</body></html>');
    win_pop.document.title = "Ad Space Preview";
    win_pop.document.close();
};
-->
</script>			
   </td>
  </tr>
</table></td>
  </tr>

</table></td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderBottomLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderBottomRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                </table></td>
                    <td>&nbsp;</td>
                    </tr>
                </table></td>
              </tr>
            </table>
<?php
}
?>